<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>

  <div class="box1"></div>
  <div class="box2"></div>
  <div class="box3"></div>
  <div class="box1"></div>
  <div class="box3"></div>
  <span class="box2"></span>
  <span class="abc box2 qwe"></span>
  <span class="box2"></span>
  <span class="box2"></span>
  <em class="box1"></em>
  <em class="box1"></em>
  <em class="box1"></em>
  <em class="box1"></em>
  
</body>
<script>

  // 使用getElementsByTagName模拟getElementsByClassName
  
  function byClassName( className ){
    const eles = document.getElementsByTagName("*");
    return [...eles].filter(val=>val.className.includes(className));
  }

  console.log( byClassName("box1") );
  console.log( byClassName("box2") );
  console.log( byClassName("box3") );
  console.log( byClassName("abc") );
  
</script>
</html>